package com.xoa.dev.jinOuWorkFlowWebService.com.weaver.docs;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.encoding.XMLType;
import java.io.IOException;


public class Test {

	public static void main(String[] args) throws IOException {


//
//		//创建 JaxWsDynamicClientFactory 工厂实例
//		JaxWsDynamicClientFactory factory=JaxWsDynamicClientFactory.newInstance();
//		//创建客户端
//		Client client=factory.createClient("http://localhost:8080/webservice/CreateWorkFlow?wsdl");
//		Object [] result;
//		QName qname;
		try {
//			//根据指定的命名空间（接口类包名）、方法名新建QName对象
//			qname=new QName("http://jinOuWorkFlowWebService.dev.xoa.com/", "createWorkFlow");


			String temp1 = "{\n" +
					" \"bt\":\"关于It重点项目议案\",\n" +
					" \"zrz\":\"张三\",\n" +
					" \"bwrq\":\"2018-08-25\",\n" +
					" \"zrzlsh\":\"001\",\n" +
					" \"wh\":\"01\",\n" +
					" \"bgtyj\":\"同意\",\n" +
					" \"mj\":\"绝密\",\n" +
					" \"jh\":\"加急\",\n" +
					" \"sh\":\"同意\",\n" +
					" \"hqbm\":\"开发部\",\n" +
					" \"wjrq\":\"2018-08-25\",\n" +
					" \"fwbh\":\"001\",\n" +
					" \"ldps\":\"同意\",\n" +
					" \"zbbm\":\"同意\", \n" +
					"  \"fj\":\"98822\",\n" +
					" \"zw\":\"98822\",\n" +
					"\"sfxyfh\":\"Y\",\n" +
					"\"field1\":\"\",\n" +
					"\"field2\":\"\",\n" +
					"\"field3\":\"\",\n" +
					"\"field4\":\"\",\n" +
					"\"field5\":\"\",\n" +
					"\"spyjs\":[\n" +
					"  {\n" +
					"   \"spbm\":\"信息部\",\n" +
					"   \"spnr\":\"同意\",\n" +
					"   \"spr\":\"张三\",\n" +
					"   \"spsj\":\"2018-08-25 10:34:00\"\n" +
					"  },\n" +
					"  {\n" +
					"   \"spbm\":\"信息部\",\n" +
					"   \"spnr\":\"不同意\",\n" +
					"   \"spr\":\"李四\",\n" +
					"   \"spsj\":\"2018-08-25 10:35:00\"\n" +
					"  }\n" +
					" ]\n" +
					"}";


			String temp3 = "{\"dh\":\"63636919\",\"fj\":\"99271\",\"zbbm\":\"董事会办公室\",\"spyjs\":[{\"spsj\":\"2019-12-12 14:19:54\",\"spnr\":\"\",\"spr\":\"张敬才\",\"spbm\":\"董事会办公室\"},{\"spsj\":\"2019-12-12 14:20:28\",\"spnr\":\"签字意见\",\"spr\":\"张敬才\",\"spbm\":\"董事会办公室\"},{\"spsj\":\"2019-12-12 14:21:25\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"}],\"fs\":\"\",\"bgthq\":\"\",\"bmsh\":\"\",\"bmqf\":\"\",\"bt\":\"测试分发002\",\"hgr\":\"\",\"ngr\":\"张敬才\",\"ys\":\"\",\"mj\":\"商密三级\",\"fwrq\":\"2019-12-12\",\"hqbm\":\"\",\"jtldyj\":\"\",\"fwbh\":\"光大办发[2019]\",\"cs\":\"1\",\"bgtsh\":\"\",\"field1\":\"253\",\"csb\":\"\",\"requestid\":\"699161\",\"zs\":\"\",\"field3\":\"\",\"zw\":\"\",\"field2\":\"\",\"jh\":\"特急\",\"field5\":\"\",\"rq\":\"2019-12-12\",\"field4\":\"\"}";









			//测试反馈json
			String temp4 = "{\n" +
                    "\n" +
                    " \"bt\":\"关于It重点项目议案\",\n" +
                    "\n" +
                    " \"zrz\":\"张三\",\n" +
                    "\n" +
                    " \"bwrq\":\"2018-08-25\",\n" +
                    "\n" +
                    " \"zrzlsh\":\"001\",\n" +
                    "\n" +
                    " \"wh\":\"01\",\n" +
                    "\n" +
                    " \"bgtyj\":\"同意\",\n" +
                    "\n" +
                    " \"mj\":\"绝密\",\n" +
                    "\n" +
                    " \"jh\":\"加急\",\n" +
                    "\n" +
                    " \"sh\":\"同意\",\n" +
                    "\n" +
                    "\"hq\":\"同意\",\n" +
                    "\n" +
                    " \"wjrq\":\"2018-08-25\",\n" +
                    "\n" +
                    " \"hqbm\":\"开发部\",\n" +
                    "\n" +
                    " \"fwbh\":\"001\",\n" +
                    "\n" +
                    " \"ldps\":\"同意\",\n" +
                    "\n" +
                    " \"zbbm\":\"同意\", \n" +
                    "\n" +
                    " \"fj\":\"1,2\",\n" +
                    "\n" +
                    " \"zw\":\"3\",\n" +
                    "\n" +
                    "\"gsbs\":\"17\",\n" +
                    "\n" +
                    "\"sfxyfh\":\"Y\",\n" +
                    "\n" +
                    "\"field1\":\"243\",\n" +
                    "\n" +
                    "\"field2\":\"13372\",\n" +
                    "\n" +
                    "\"field3\":\"报文流程审批 2019-12-16 17:39:45\",\n" +
                    "\n" +
                    "\"field4\":\"1\",\n" +
                    "\n" +
                    "\"field5\":\"2\",\n" +
                    "\n" +
                    "\"spyjs\":[\n" +
                    "\n" +
                    " {\n" +
                    "\n" +
                    "  \"spbm\":\"信息部\",\n" +
                    "\n" +
                    "  \"spnr\":\"同意\",\n" +
                    "\n" +
                    "  \"spr\":\"张三\",\n" +
                    "\n" +
                    "  \"spsj\":\"2018-08-25 10:34:00\"\n" +
                    "\n" +
                    " },\n" +
                    "\n" +
                    " {\n" +
                    "\n" +
                    "  \"spbm\":\"信息部\",\n" +
                    "\n" +
                    "  \"spnr\":\"不同意\",\n" +
                    "\n" +
                    "  \"spr\":\"李四\",\n" +
                    "\n" +
                    "  \"spsj\":\"2018-08-25 10:35:00\"\n" +
                    "\n" +
                    " }\n" +
                    "\n" +
                    " ]\n" +
                    "\n" +
                    "}";

			String temp2 = "remark";


			String nei = "{\"dh\":\"\",\"fj\":\"99520\",\"zbbm\":\"办公厅/党委办公室\",\"spyjs\":[{\"spsj\":\"2019-12-20 13:33:40\",\"spnr\":\"\",\"spr\":\"王岩\",\"spbm\":\"办公厅/党委办公室\"},{\"spsj\":\"2019-12-20 13:34:49\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"},{\"spsj\":\"2019-12-20 13:35:16\",\"spnr\":\"\",\"spr\":\"王岩\",\"spbm\":\"办公厅/党委办公室\"},{\"spsj\":\"2019-12-20 13:35:32\",\"spnr\":\"\",\"spr\":\"王岩\",\"spbm\":\"办公厅/党委办公室\"},{\"spsj\":\"2019-12-20 13:36:27\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"}],\"fs\":\"\",\"bgthq\":\"\",\"bmsh\":\"\",\"bmqf\":\"\",\"bt\":\"集团向金瓯发文测试20191220\",\"hgr\":\"\",\"ngr\":\"王岩\",\"ys\":\"\",\"mj\":\"商密三级\",\"fwrq\":\"2019-12-20\",\"hqbm\":\"\",\"jtldyj\":\"\",\"fwbh\":\"光大办发[2019]0001\",\"cs\":\"无\",\"bgtsh\":\"\",\"field1\":\"\",\"csb\":\"\",\"requestid\":\"699306\",\"zs\":\"\",\"field3\":\"\",\"zw\":\"99521\",\"field2\":\"\",\"jh\":\"急\",\"field5\":\"\",\"rq\":\"2019-12-20\",\"field4\":\"\"}";

			String test = "{\"dh\":\"\",\"fj\":\"129086\",\"zbbm\":\"科技创新事业部\",\"spyjs\":[{\"spsj\":\"2019-12-27 19:51:56\",\"spnr\":\"\",\"spr\":\"陈田\",\"spbm\":\"科技创新事业部\"},{\"spsj\":\"2019-12-27 19:52:32\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"},{\"spsj\":\"2019-12-27 19:49:10\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"},{\"spsj\":\"2019-12-27 19:50:59\",\"spnr\":\"\",\"spr\":\"陈田\",\"spbm\":\"科技创新事业部\"},{\"spsj\":\"2019-12-27 19:51:44\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"},{\"spsj\":\"2019-12-27 19:50:38\",\"spnr\":\"\",\"spr\":\"系统管理员\",\"spbm\":\"\"}],\"fs\":\"\",\"bgthq\":\"\",\"bmsh\":\"\",\"bmqf\":\"\",\"bt\":\"集团向金瓯发文测试1227-1\",\"hgr\":\"\",\"ngr\":\"陈田\",\"ys\":\"\",\"mj\":\"商密二级\",\"fwrq\":\"2019-12-27\",\"hqbm\":\"\",\"jtldyj\":\"\",\"fwbh\":\"光大办发[2019]0001\",\"cs\":\"无\",\"bgtsh\":\"\",\"field1\":\"\",\"csb\":\"\",\"requestid\":\"687089\",\"zs\":\"\",\"field3\":\"\",\"zw\":\"129087\",\"field2\":\"\",\"jh\":\"急\",\"field5\":\"\",\"rq\":\"2019-12-27\",\"field4\":\"\"}";
			Object[] objs = new Object[]{test,temp2};
			Object connect = getConnect("http://localhost:8080/webservice/CreateWorkFlow", "http://jinOuWorkFlowWebService.dev.xoa.com/", "createWorkFlow", objs);
			System.out.println(connect);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}




    //获取连接
    public static Object getConnect(String url, String qname, String method, Object[] objs){

        Object result = "0";
        Service service = null;
        Call call = null;

        try {

            service = new Service();
            call = (Call)service.createCall();

            call.setTargetEndpointAddress(url);// 远程调用路径
            call.setOperationName(new QName(qname, method)); //命名空间和方法
            call.addParameter("strJson", // 参数名
                    XMLType.XSD_STRING,// 参数类型:String
                    ParameterMode.IN);// 参数模式：'IN' or 'OUT'
            call.addParameter("remark",
                    XMLType.XSD_STRING,
                    ParameterMode.IN);
            //返回类型
            call.setReturnType(XMLType.XSD_STRING,String.class);

            //远程调用
            result = (String)call.invoke(objs);
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            //释放资源
            if(call!=null)
                call=null;
            if(service!=null)
                service=null;
        }
        return result == null ?"0":result;
    }


}
